<%@ page language="java" contentType="text/html" pageEncoding="utf-8"%>
<%@include file="/WEB-INF/pages/common/common.jsp" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
  <head>
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
    <%@include file="/resources/datepicker/datepicker.jsp"%>
    <meta http-equiv="pragma" content="no-cache" />
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
    <title>
      <spring:message code="title.ipic.target"/>
    </title>
    <style type="text/css">
      .font_stress{ color: red;font-size: 13px;font-weight:bold; }
    </style>
    <script type="text/javascript">
      var operateDialog;
      var datagrid;
      $(function() {
        datagrid=$('#datagrid').datagrid({
          onClickRow:function(rowIndex){
            var rows = datagrid.datagrid('getRows');
            for ( var i = 0; i < rows.length; i++) {
              datagrid.datagrid('endEdit', i);
            }
             datagrid.datagrid('beginEdit', rowIndex); 
              }
              })
              });

              function save_(){

                if($("#supplierCode").val()==''){
                  $.messager.alert('提示','供应商不能为空');
                  return;
                }
                if($("#year").val()==''){
                  $.messager.alert('提示','年份不能为空');
                  return;
                }

                var isV =$("#tableForm").form("validate");
                if(!isV) return;
                var rows = datagrid.datagrid('getRows');
                for ( var i = 0; i < rows.length; i++) {
                  datagrid.datagrid('endEdit', i);
                }
                var updateRows = $('#datagrid').datagrid('getChanges');
                if(updateRows==''){
                  $.messager.alert('<spring:message code='msg.tip'/>',"请填写月份记录后提交数据!");
                  return;
                }

                imonJYRH.showZone();
                var effectData = new Object();
                effectData["answerDetail"] = JSON.stringify(rows);
                effectData["answer"] =  JSON.stringify(imonJYRH.serializeObject($("#tableForm *")));

                $.ajax({
                  url : '${path}/business/supplier_quality/answer_problem/ajaxAdd.do',
                  data : effectData,
                  cache : false,
                  async : true,
                  dataType : "json",
                  success : function(reMsg) {
                    if(reMsg.success){
                      parent.returnResult();
                      message.show({ msg : reMsg.msg,title : '<spring:message code='msg.tip'/>',showType:'slide'});
                    }else{
                      if(!imonJYRH.isBlank(reMsg.obj)){
                        $.messager.alert('<spring:message code='msg.tip'/>',reMsg['obj']);
                      }else{
                        $.messager.alert('<spring:message code='msg.tip'/>',reMsg['msg']);
                      }
                    }
                    imonJYRH.hideZone();
                  }
                  });
                }
                function dialogSupplier_(){
                  var href = '${path}/basedata/supplier/dialogUI.do';
                  operateDialog = $("#operateDialog").dialog({
                    title : '<spring:message code='msg.dialog.choose'/>',
                    width : 650,
                    height : 400
                    });
                    $("#operateIFrame")[0].src=href;
                    operateDialog.dialog('open');
                  }
                  function dialogSupplierReturn(row){
                    $("#supplierId").val(row['id']);
                    $("#supplierCode").val(row['code']);
                    $("#supplierName").val(row['name']);
                    operateDialog.dialog('close');
                  }
                </script>
              </head>
              <body class="easyui-layout">
                <div data-options="region:'center'">
                  <div class="datagrid-toolbar" style="height:410px">
                    <table width="100%" id="tableForm">
                      <tr>
                        <td align="right">
                          <span style="color:red;">
                            *
                          </span>
                          SupplierCode供应商编码：
                        </td>
                        <td>
                          <input type="hidden" id='supplierId' name="supplierId"/>
                          <input type="text" id="supplierCode" onclick="dialogSupplier_();" readonly="true"/>
                        </td>
                        <td align="right">
                          SupplierName供应商名称：
                        </td>
                        <td>
                          <input type="text" id="supplierName" style="width: 180px;" disabled/>
                        </td>
                        <td align="right">
                          <span style="color:red;">
                            *
                          </span>
                          Year年份：
                        </td>
                        <td>
                          <input 
                              type="text"
                              name="year"
                              value="${year}"
                              id="year"
                              onFocus="WdatePicker({isShowClear:false,isShowToday:false,dateFmt:'yyyy',readOnly:true})"
                              class="field Wdate"/>
                        </td>
                      </tr>
                    </table>
                    <hr width="650px"/>
                    <table width="100%" id="datagrid" singleSelect="true"  class="tableForm">
                      <thead>
                        <tr>
                          <th field="month" width="60"  hidden="true">
                            >月份
                          </th>
                          <th field="months" width="60">
                            月份
                          </th>
                          <th 
                              field="type"
                              width="150"
                               data-options="editor:{type:'combobox',options:{valueField:'id',panelHeight:'auto',textField:'text',editable :false, 
                               data: [{ id: 'GOOD,VERY QUICK' , text: 'GOOD,VERY QUICK', selected: 'true' },{ id: 'SATISFACTORY', text: 'SATISFACTORY' },{ id: 'NOT GOOD', text: 'NOT GOOD' }] 
                               ,
                                 onSelect:function(record){ 
                                        var row=datagrid.datagrid('getSelected');
                                        if(record.id=='GOOD,VERY QUICK'){
                                     	  row['value']= 5;
                                        }else if(record.id=='SATISFACTORY'){
                                      	  row['value']=3;
                                        }else {
                                     	   row['value']=0;
                                        }  
						           }   
                                }
                               
                               }">

                            选择
                          </th>
                          <th field="value" width="150">
                            得分
                          </th>
                          <th field="comment" width="290" data-options="editor:{type:'text'}">
                            评论
                          </th>
                        </tr>
                      </thead>
                      <tbody>
                        <tr>
                          <td  hidden="true">
                            01
                          </td>
                          <td>
                            一月
                          </td>
                          <td id="td1">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            02
                          </td>
                          <td>
                            二月
                          </td>
                          <td id="td2">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            03
                          </td>
                          <td>
                            三月
                          </td>
                          <td id="td3">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            04
                          </td>
                          <td>
                            四月
                          </td>
                          <td id="td4">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            05
                          </td>
                          <td>
                            五月
                          </td>
                          <td id="td5">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            06
                          </td>
                          <td>
                            六月
                          </td>
                          <td id="td6">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            07
                          </td>
                          <td>
                            七月
                          </td>
                          <td id="td7">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            08
                          </td>
                          <td>
                            八月
                          </td>
                          <td id="td8">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            09
                          </td>
                          <td>
                            九月
                          </td>
                          <td id="td9">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            10
                          </td>
                          <td>
                            十月
                          </td>
                          <td id="td10">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            11
                          </td>
                          <td>
                            十一月
                          </td>
                          <td id="td11">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                        <tr>
                          <td  hidden="true">
                            11
                          </td>
                          <td>
                            十二月
                          </td>
                          <td id="td12">
                          </td>
                          <td>
                          </td>
                          <td>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                    <br />
                    <div align="right">
                      <a class="easyui-linkbutton" href="javascript:void(0);" iconCls="icon-save" onclick="save_()">
                        Save保存
                      </a>
                      <a 
                          class="easyui-linkbutton"
                          href="javascript:void(0);"
                          iconCls="icon-no"
                          onclick="parent.operateDialog.dialog('close');">

                        Close关闭
                      </a>
                    </div>
                  </div>
                </div>
                <div 
                    id="operateDialog"
                    class="easyui-dialog"
                    data-options="iconCls:'icon-save',resizable:true,modal:true,closed: true,collapsible:true,maximizable:true">

                  <iframe scrolling="auto" id='operateIFrame' frameborder="0"  src="" style="width:100%;height:100%;"/>
                </div>

              </body>
            </html>
